import 'package:hrf_app/pages/menu/project/project_detail/widgets/projectBugTab.dart';
import 'package:hrf_app/pages/menu/project/project_detail/widgets/projectDocTab.dart';
import 'package:hrf_app/pages/menu/project/project_detail/widgets/projectNotebootTab.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'index.dart';

class ProjectDetailPage extends GetView<ProjectDetailController> {
  const ProjectDetailPage({super.key});

  // 主视图
  Widget _buildView() {
    return Column(
      children: [
        TDTabBar(
          tabs: [
            TDTab(
              text: "BUG",
            ),
            TDTab(
              text: "笔记",
            ),
            TDTab(
              text: "文档",
            )
          ],
          onTap: controller.onTap,
          // 修改: 使用 controller.onTap 方法
          controller: controller.tabController,
          backgroundColor: Colors.white,
          showIndicator: true,
        ),
        Expanded(
          child: IndexedStack(
            index: controller.currentIndex, // 新增: 根据 currentIndex 显示不同的内容
            children: [
              ProjectBugTabPage(projectId: controller.projectId),
              ProjectNotebookTabPage(projectId: controller.projectId),
              ProjectDocTabPage(),
            ],
          ),
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ProjectDetailController>(
      init: ProjectDetailController(),
      id: "project_detail", // 修改: 将 id 参数改为 "project_detail"
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("项目详情")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
